package com.rockcent.mall.lib.domain;

import com.rockcent.common.domain.IDEntityMall;
import com.rockcent.mall.lib.domain.enumclass.FileKind;
import com.rockcent.mall.lib.domain.enumclass.FileStatus;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;

@Entity
@Table(name = "upload_file")
@DynamicInsert
@DynamicUpdate
public class UploadFile extends IDEntityMall {

    @Column(columnDefinition = "varchar(255) comment'文件名'")
    private String name;
    @Column(columnDefinition = "int comment '文件大小'")
    private Integer size;
    @Column(columnDefinition = "varchar(255) comment '文件类型'")
    private String type;
    @Column(columnDefinition = "varchar(255) comment '文件路径'")
    private String path;
    @Column(columnDefinition = "varchar(255) comment '值对象名称'")
    private String entity;
    @Column(columnDefinition = "bigint comment '值对象主键'")
    private Long entityId;
    @Column(columnDefinition = "int comment '排序字段'")
    private Integer sort = 0;
    @Column(columnDefinition = "varchar(50) comment '用途/种类'")
    @Enumerated(EnumType.STRING)
    private FileKind kind = FileKind.PICTURE;
    @Column(columnDefinition = "varchar(50) comment '状态'")
    @Enumerated(EnumType.STRING)
    private FileStatus status = FileStatus.INTERIM;

    // 类别图标
    public static final String ENTITY_CATEGORY_ICON = "CategoryIcon";
    // 类别图片
    public static final String ENTITY_CATEGORY = "Category";

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getEntity() {
        return entity;
    }

    public void setEntity(String entity) {
        this.entity = entity;
    }

    public Long getEntityId() {
        return entityId;
    }

    public void setEntityId(Long entityId) {
        this.entityId = entityId;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public FileKind getKind() {
        return kind;
    }

    public void setKind(FileKind kind) {
        this.kind = kind;
    }

    public FileStatus getStatus() {
        return status;
    }

    public void setStatus(FileStatus status) {
        this.status = status;
    }


    @Override
    public String toString() {
        return "UploadFile{" +
                "name='" + name + '\'' +
                ", size=" + size +
                ", type='" + type + '\'' +
                ", path='" + path + '\'' +
                ", entity='" + entity + '\'' +
                ", entityId=" + entityId +
                ", sort=" + sort +
                ", kind=" + kind +
                ", status=" + status +
                '}';
    }
}